import { Account } from "../types/account";
import { SERVER_HOST } from "./host"

export const fetchAccounts= async (handler:React.Dispatch<React.SetStateAction<Account[]>>) => {
    const resp = await fetch(`${SERVER_HOST}/api/account`)
    const data = await resp.json();
    if (data.error) {
        throw new Error(data.error)
    }
    handler(data.data ?? [])
}